//
//  HighvioView.m
//  CarLife
//
//  Created by yu on 2018/7/11.
//  Copyright © 2018年 jpas. All rights reserved.
//

#import "HighvioView.h"

@interface HighvioView ()

@property (nonatomic, strong) UIButton *cancelBtn;

@property (nonatomic, strong) UIImageView *imgView;

@end

@implementation HighvioView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.layer.shadowRadius = 2;
        self.layer.shadowOpacity = 0.3;
        self.layer.shadowColor = UIColor.lightGrayColor.CGColor;
        
        CGFloat margin10 = 10; CGFloat margin15 = 15;
        
        _imgView = [[UIImageView alloc] init];
        _imgView.image = IMAGE_NAMED(@"highvioImg");
        [self addSubview:_imgView];
        
        _reasonLabel = [[UILabel alloc] init];
//        _reasonLabel.backgroundColor = [UIColor orangeColor];
        _reasonLabel.textColor = UIColor.blackColor;
        _reasonLabel.font = Font_NAME_SIZE(@"PingFangSC-Medium", 16);
        [self addSubview:_reasonLabel];
        
        _addressLabel = [[UILabel alloc] init];
//        _addressLabel.backgroundColor = [UIColor greenColor];
        _addressLabel.textColor = kTextLightBlackColor;
        _addressLabel.font = SYSTEM_FONT(14);
        [self addSubview:_addressLabel];
        
        _cancelBtn = [[UIButton alloc] init];
        [_cancelBtn setImage:IMAGE_NAMED(@"highviocancel") forState:UIControlStateNormal];
        [_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_cancelBtn];
        
        _imgView.sd_layout
        .leftSpaceToView(self, margin15)
        .centerYEqualToView(self)
        .widthIs(16)
        .autoHeightRatio(1.56);
        
        _cancelBtn.sd_layout
        .rightSpaceToView(self, margin10/2)
        .topSpaceToView(self, margin10/2)
        .heightIs(30)
        .widthEqualToHeight();
        
        _reasonLabel.sd_layout
        .leftSpaceToView(_imgView, margin10)
        .topSpaceToView(self, margin15)
        .rightSpaceToView(_cancelBtn, 0)
        .autoHeightRatio(0);
        [_reasonLabel setMaxNumberOfLinesToShow:2];
        
        _addressLabel.sd_layout
        .leftEqualToView(_reasonLabel)
        .rightSpaceToView(self, margin10)
        .topSpaceToView(_reasonLabel, margin10)
        .bottomSpaceToView(self, margin10);
        [_addressLabel setMaxNumberOfLinesToShow:2];
        
    }
    return self;
}

- (void)cancelAction {
    if (_cancelBlock) {
        _cancelBlock();
    }
}


@end
